
import taxonomy
from whiff import resolver
from whiff.middleware import displayTraceback
import showTree

env = {
    'treeView.leafFlag': '<img src="doc.png" border="0">',
    'treeView.expandedFlag': '<img src="folder.open.png" border="0">',
    'treeView.closedFlag': '<img src="folder.png" border="0">',
    'treeView.targetPrefix': '<a id="focusNode"></a><b><em>',
    'treeView.targetSuffix': '</em></b>',
    'treeView.bodyPrefix': "<div style=\"border-left:3px solid green; padding-left:10px\">",
    'treeView.bodySuffix': "</div>",
    'treeView.tailPrefix': "<div style=\"border-left:3px solid yellow; padding-left:10px\">",
    'treeView.tailSuffix': "</div>"
    }

testapp = resolver.moduleRootApplication("/", showTree,
                                         #exception_middleware=None,
                                         exception_middleware=displayTraceback.__middleware__,
                                         on_not_found=None, # show traceback (could comment)
                                         environment = env,
                                         )

treeFinder = taxonomy.TreeResource()
testapp.registerResourceFinder(prefix="tree", finder=treeFinder)
sessionFinder = taxonomy.SearchResource()
testapp.registerResourceFinder(prefix="search", finder=sessionFinder)

if __name__=="__main__":
    import wsgiref.simple_server
    print "taxonomy tree server"
    print "serving wsgi at 8888"
    srv = wsgiref.simple_server.make_server('localhost', 8888, testapp)
    srv.serve_forever()
                    
